        function timer(){
		# Wait until tester have been completed - or $MAX_WAIT secs whichever is shorter
		TOT_WAIT=0
		short_wait=3
		while true; do 
		
			if  ps ax | grep -v grep  |  grep $!> /dev/null ; then 
				if [ $TOT_WAIT -gt $timeout ]; then
					kill $! 2> /dev/null;
					break
				fi
				sleep $short_wait
				((TOT_WAIT += $short_wait))
			else
				break;
			fi  
		done;
		((total_time += $TOT_WAIT))
	}
        
        
        function ejecutarKorat() {
            nodes=1
            while true; do
                fullOutputFileName=$nodes"_"$2
                java -cp $SWD/../lib/korat.jar:. korat.Korat --class $1  --args $nodes,$nodes,$nodes,0,$nodes --serialize $fullOutputFileName & timer
                if [ $total_time -gt $timeout ]; then
                    break
                fi
                let nodes=$nodes+1;
            done
        }
        
        #1 : nombre estructura (ListAsSet, AltGraph, etc)
        #2 : archivo salida
        #3 : medida te tiempo usada
        #4 : tiempo
	total_time=0
	short_wait=0
	#chequeo de parametros
	if [ "$#" -lt "4" ] ; then 
		echo "Incorrect usage ! Example:" 
		echo './generateTestSuite.sh LabelledAltGraph salida.ko -s  <seconds>' 
		echo 'or' 
		echo './generateTestSuite.sh LabelledAltGraph salida.ko -m  <minutes>'
		echo 'or' 
		echo './generateTestSuite.sh LabelledAltGraph salida.ko -h  <hours>'
		exit 1 
	fi 
	#what ever the entry is (hours, minutes, seconds), it is translated to  seconds.
	timeout=$4
	if [ "$3" = "-m" ] ; then
		timeout=$[timeout*60]	
	fi 
	if [ "$3" = "-h" ] ; then 
		timeout=$[timeout*3600]	
	fi 
    
	echo "Running with Time Out:" $timeout "sec".
	SWD=$(pwd)
        ejecutarKorat $1 $2
	echo "Generation ended"